package com.binguo.wxapi.controller;

import com.binguo.model.wxapi.vo.ShopPlaceListVO;
import com.binguo.wxapi.passengerflow.PassengerFlowService;
import com.binguo.wxapi.result.Result;
import com.binguo.wxapi.result.ResultGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@RestController
@RequestMapping
public class ShopPlaceController {
    private static Logger logger = LoggerFactory.getLogger(ShopPlaceController.class);

    @Resource
    private PassengerFlowService passengerFlowService;

    /**
     * 获取列表
     *
     * @return
     */
    @PostMapping(value = "/api/wxapp/shopplace/list", produces = APPLICATION_JSON_VALUE)
    public Result shopplaceList(@RequestParam(value = "shopId") Integer shopId) {

        logger.info("get shopplaceList : {}", shopId);
        ShopPlaceListVO result = passengerFlowService.getStatisticData(shopId);
        if (result != null) {
            return ResultGenerator.genSuccessResult(result);
        }
        return ResultGenerator.genFailResult(null);
    }


}
